#include <iostream>
#include <string>
#include <math.h>
#include "vector.h"

#include<stdlib.h>
#include <time.h>

using namespace std;

//used to display a vector
void displayVector(string,Vector);

void main()
{
	//v1 to be set differnt from v2
	//v3 is a pointer of size 3
	//v1 = v4
	//r holds the value for randomly generated vector
	Vector *v1,*v2,*v4,*r;
	double dot,v3[3];
	double *v3Ptr = v3;
	int max,min; //for random vector

	//Set v3 via pointer.
	*v3Ptr=4;
	*(v3Ptr+1)=-2;
	*(v3Ptr+2)=8;

	v1 = new Vector(v3Ptr); //use pointer array in constructor
	v2 = new Vector(); //default constructor
	v4 = new Vector(*v1); //array constructor
	r = new Vector();

	displayVector("v1",*v1);
	
	//checks if 2 is zero. will be, since default constructor
	cout << "Returns 1 if v2 is zero: " << v2->getZero() << endl;

	v2->setVector(7,-9,18); //set with 3 doubles
	displayVector("v2",*v2);
	displayVector("v4",*v4);

	//checks if 2 is zero. now set, so no
	cout << "Returns 1 if v2 is zero: " << v2->getZero() << endl;

	//get the sum of v1 and v2
	cout << endl << "Sum" << endl;
	displayVector("sum",v1->getSum(*v2));
	
	//get the difference of v1 and v2
	cout << endl << "Diff" << endl;
	displayVector("diff",v1->getDiff(*v2));

	//get the magnitude of the vectors
	cout << endl << "Mag" << endl;
	cout << v1->getMag() << endl;
	cout << v2->getMag() << endl;

	//get the squared magnitude of the vectors
	cout << endl << "Mag Squared" << endl;
	cout << v1->getMagSq() << endl;
	cout << v2->getMagSq() << endl;

	//get the direction of the vectors
	cout << endl << "Direction" << endl;
	cout << v1->getDir(*v2) << endl;

	//get the dot product of the vectors
	cout << endl << "Dot" << endl;
	cout << v1->getDot(*v2) << endl;

	//get the cross product of the vectors
	cout << endl << "Cross" << endl;
	displayVector("cross",v1->getCross(*v2));

	//check if vectors are equal
	cout << endl << "Check if v1 == v4" << endl;
	cout << v1->getEqual(*v4) << endl;

	//generate random vectors
	cout << endl << "Random" << endl;
	//between 10 to 100
	cout << "10 to 100" << " -> ";
	min=10;max=100;
	r->setRandom(min,max);
	displayVector("r",*r);
	//between 1 to 1000
	cout << "1 to 1000" << " -> ";
	min=1;max=1000;
	r->setRandom(min,max);
	displayVector("r",*r);
	//between 5 to 65
	cout << "5 to 65" << " -> ";
	min=5;max=65;
	r->setRandom(min,max);
	displayVector("r",*r);

	//treat vectors as points, get distance between
	cout << endl << "Distance" << endl;
	cout << "v1 -> v2 = " << v1->getDist(*v2) << endl;

	//treat vectors as points, get squared distance between
	cout << endl << "Distance Squared" << endl;
	cout << "v1 -> v2 = " << v1->getDistSq(*v2) << endl;

	//generate unit vector of a vector
	cout << endl << "Unit Vector" << endl;
	displayVector("v1",v1->getUnitVector());
	displayVector("v2",v2->getUnitVector());

	//treat vectors as points, interpolate a vector between them
	cout << endl << "Interpolation - v1->v2" << endl;
	displayVector("P=0",v1->getInterpolation(0,*v2));
	displayVector("P=.25",v1->getInterpolation(0.25,*v2));
	displayVector("P=.5",v1->getInterpolation(0.5,*v2));
	displayVector("P=.75",v1->getInterpolation(0.75,*v2));
	displayVector("P=1",v1->getInterpolation(1,*v2));
}

void displayVector(string s,Vector v)
{
	cout << s << " = (" << v.getX() << "," << v.getY() << "," << v.getZ() << ")" << endl;
}